package net.huashitong.ssydt.exam.entity.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import net.huashitong.ssydt.exam.constant.ExamConsts;
import net.huashitong.ssydt.exam.entity.SsExamTestRecord;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.08.30
 */
@ApiModel(value = "TestRecordsListOutVO", description = "记录列表对象")
public class TestRecordsListOutVO implements Serializable {

    private static final long serialVersionUID = -4471059594028834002L;

    @ApiModelProperty("记录id")
    private Long id;//记录id
    @ApiModelProperty("阶段数")
    private Integer stageNumber;//阶段数
    @ApiModelProperty("练习状态 01 进行中 02 已完成 ")
    private String testState;//练习状态 01 进行中 02 已完成
    @ApiModelProperty("完成数")
    private Integer finishNumber;//完成数
    @ApiModelProperty("题目数")
    private Integer questionNumber;//题目数
    @ApiModelProperty("正确数")
    private Integer correctNumber;//正确数
    @ApiModelProperty("正确率")
    private BigDecimal correctRate = BigDecimal.valueOf(0);
    @ApiModelProperty("作答时间")
    private Date gmtCreate;//作答时间

    public TestRecordsListOutVO() {

    }

    public TestRecordsListOutVO(SsExamTestRecord ssExamTestRecord) {
        this.id = ssExamTestRecord.getId();
        this.stageNumber = ssExamTestRecord.getStageNumber();
        this.testState = ssExamTestRecord.getTestState();
        this.finishNumber = ssExamTestRecord.getFinishNumber();
        this.questionNumber = ssExamTestRecord.getQuestionNumber();
        this.correctNumber = ssExamTestRecord.getCorrectNumber();
        this.gmtCreate = ssExamTestRecord.getGmtCreate();
        if (ssExamTestRecord.getTestState().equals(ExamConsts.TestState.FINISH)) {
            this.correctRate = BigDecimal.valueOf(this.getCorrectNumber())
                    .divide(BigDecimal.valueOf(this.getQuestionNumber()), 2, BigDecimal.ROUND_DOWN);
            this.finishNumber = ssExamTestRecord.getQuestionNumber();
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getStageNumber() {
        return stageNumber;
    }

    public void setStageNumber(Integer stageNumber) {
        this.stageNumber = stageNumber;
    }

    public String getTestState() {
        return testState;
    }

    public void setTestState(String testState) {
        this.testState = testState;
    }

    public Integer getFinishNumber() {
        return finishNumber;
    }

    public void setFinishNumber(Integer finishNumber) {
        this.finishNumber = finishNumber;
    }

    public Integer getQuestionNumber() {
        return questionNumber;
    }

    public void setQuestionNumber(Integer questionNumber) {
        this.questionNumber = questionNumber;
    }

    public Integer getCorrectNumber() {
        return correctNumber;
    }

    public void setCorrectNumber(Integer correctNumber) {
        this.correctNumber = correctNumber;
    }

    public BigDecimal getCorrectRate() {
        return correctRate;
    }

    public void setCorrectRate(BigDecimal correctRate) {
        this.correctRate = correctRate;
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }
}
